<template>
  <div>
    <div>
      <!--      卡片区域-->
      <el-card class="box-card">
        <el-row>
          <el-col :span="4"></el-col>
          <el-col :span="8">
            <h1>会议管理</h1>
          </el-col>
          <el-col :span="4"></el-col>
        </el-row>
      </el-card>
    </div>
    <div>
      <el-card class="box-card1">
        <!--        栅格位置-->
        <el-row :gutter="20">
          <el-col :span="4">
            <el-input v-model="queryinfo.m_rule" placeholder="规则编号" clearable>
            </el-input>
          </el-col>
          <el-col :span="4" :offset="1">
            <el-select v-model="queryinfo.m_state" placeholder="会议状态" clearable>
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-col>
          <el-col :span="4" :offset="1">
            <el-button type="primary" @click="getMeetings()">查询</el-button>
            <el-button type="primary" icon="el-icon-plus" @click="dialogVisible = true">新建会议</el-button>
          </el-col>
        </el-row>
        <!--        表格信息展示-->
        <div>
          <el-table :data="meetings" style="width: 100%">
            <el-table-column type="index" width="80" label="序号"></el-table-column>
            <el-table-column prop="theme" label="会议主题" width="180"></el-table-column>
            <el-table-column prop="content" label="会议内容" width="180"></el-table-column>
            <el-table-column prop="state" label="会议状态" width="180"></el-table-column>
            <el-table-column prop="holdtime" label="会议时间"></el-table-column>
            <el-table-column label="操作">
              <template>
                <el-button size="mini" round type="primary">编辑</el-button>
              </template>
            </el-table-column>
          </el-table>
          <!--        分页区域-->
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="queryinfo.pagenum"
            :page-sizes="[10, 20, 30, 40]"
            :page-size="queryinfo.pagesize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total" style="margin-top: 20px" align="center">
          </el-pagination>
        </div>
      </el-card>
    </div>
    <el-dialog title="新建会议" :visible.sync="dialogVisible" width="30%" center>
      <!--主题区域-->
      <el-form ref="form" label-width="80px">
        <el-form-item label="会议主题">
          <el-input></el-input>
        </el-form-item>
        <el-form-item label="会议内容">
          <el-input type="textarea"></el-input>
        </el-form-item>
        <el-form-item label="会议时间">
          <el-date-picker value-format="yyyy-MM-dd" type="date" placeholder="选择日期"></el-date-picker>
        </el-form-item>
      </el-form>
      <!--底部区域-->
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="dialogVisible = false">创  建</el-button>
        <el-button @click="dialogVisible = false">取 消</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data () {
    return {
      dialogVisible: false,
      meetings: [],
      total: 0,
      options: [{
        value: '-1',
        label: '待进行'
      }, {
        value: '0',
        label: '进行中'
      }, {
        value: '1',
        label: '完成'
      }],
      // 获取文档信息参数对象
      queryinfo: {
        m_rule: '',
        m_state: '',
        // 当前页数
        pagenum: 0,
        // 显示条数
        pagesize: 0
      }
    }
  },
  created () {
    this.getMeetings()
  },
  methods: {
    async getMeetings () {
      if ((this.queryinfo.m_rule !== '') || (this.queryinfo.m_state !== '')) {
        this.queryinfo.pagenum = 0
      }
      const { data: rsp } = await this.$http.get('/meeting', { params: this.queryinfo })
      if (rsp.status !== 200) return this.$message.error('数据获取失败')
      this.meetings = rsp.data
      this.total = rsp.total
      // this.queryinfo.pagenum = 0
      console.log(rsp)
    },
    // 监听pagsize
    handleSizeChange (newSize) {
      this.queryinfo.pagesize = newSize
      this.getMeetings()
    },
    // 监听页码值改变
    handleCurrentChange (newPage) {
      this.queryinfo.pagenum = newPage
      this.getMeetings()
    }
  }
}
</script>

<style scoped>
  .box-card1 {
    margin-top: 10px;
  }

  .pbt {
    margin-top: 10px;
  }
</style>
